<template>
	<gui-page ref="guiPage" :customHeader="true">
		<template v-slot:gHeader>
			<nav-bar-custom left-icon="left" :title="$t('distributedEnter.scanRecord')"></nav-bar-custom>
		</template>
		<template v-slot:gBody>
			<view v-if="data.barcodeList.length == 0" class="noticeHooks">
				{{ data.barcodeList.length == 0 ? $t('stockManage.notAvailable') : $t('stockManage.without') }}
			</view>
			<view class="record-card" v-for="(item, index) in data.barcodeList" :key="`${item.barcode}` + `${index}`"
				v-else>
				<uni-icons class="close-icons" type="closeempty" color="#9C9C9C" size="30"
					@click="handelClosePopup(index, item)"></uni-icons>
				<view class="card-mini-head">
					<view class="title-line"></view>
					<text v-if="item.goalLocationCode == '' || item.goalLocationCode == undefined" style="color:red">{{
						$t('translationImage.serialNumber') }}：{{ data.barcodeList.length - index }}</text>
					<text v-else>{{ $t('translationImage.serialNumber') }}：{{ data.barcodeList.length - index }}</text>
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedOut.barcode') }}：</text>{{ item.barcode }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.materialCode') }}：</text>{{ item.materialCode
					}}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.materialName') }}：</text>{{ item.materialName
					}}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.materialSpec') }}：</text>{{ item.materialSpec
						||
						'' }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.uom') }}：</text>{{ item.unit }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedOut.warehouse') }}：</text>{{ item.warehouseCode }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.qty') }}：</text>{{ item.currentQty }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('translationImage.positionLocation') }}：</text>{{
						item.locationCode }}
				</view>
				<view v-if="item.goalLocationCode == '' || item.goalLocationCode == undefined"
					class="custom-card-itemOne">
					<text style="color: red;" class="item-info-title">{{ $t('translationImage.afterAdjusting')
						}}：</text>{{
							item.goalLocationCode }}
				</view>
				<view v-else class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('translationImage.afterAdjusting') }}：</text>{{
						item.goalLocationCode }}
				</view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
import { navigate } from '@/utils/routerSkip.js';
import { useStore } from "vuex";
import { basPdaOperationLogFn } from '@/utils/index.js';
import { OPERATION_DEL, OPERATION_LOOK } from '@/constant/index.js'
import { ref, reactive, onMounted, watch, computed, toRaw } from 'vue';
import { cancelOccupy } from '@/api/api.js'
//JS国际化引入
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
let store = useStore();
let data = reactive({
	barcodeList: [],//条码数组
})

onMounted(() => {
	try {
		let inputParameter = '无'
		let returnParameter = JSON.stringify(data.barcodeList)
		let operationPicture = '原材料库内调整'
		let callInterface = res.rquestUrl
		let opertionParmes = {
			inputParameter,
			returnParameter,
			operationPicture,
			callInterface,
			responseCode: '无',//返回状态
			errorMessage: '无',//错误信息
			isPass: 'Y',//是否成功 Y N
			operationType: OPERATION_LOOK,
			module: 'WMS',
			source: "PDA",
		}
		basPdaOperationLogFn(opertionParmes)
	} catch (error) {
	}
})

data.barcodeList = computed(() => {
	return store.state.rmWarehouseChangeList
})
const handelClosePopup = (index, item) => {
	let parmes = {
		locationName:item.goalLocationName,
		locationCode: item.goalLocationCode,
		materialCode: item.materialCode,
		id: item.goaLlocationId,
		barcode: item.barcode
	}
	// 取消占用庫位
	cancelOccupy([parmes]).then(res => {
		try {
			let inputParameter = JSON.stringify(parmes)
			let returnParameter = JSON.stringify(res)
			let operationPicture = '原材料库内调整'
			let callInterface = res.rquestUrl
			let opertionParmes = {
				inputParameter,
				returnParameter,
				operationPicture,
				callInterface,
				responseCode: res.code,//返回状态
				errorMessage: res.msg,//错误信息
				isPass: res.code == 0 ? 'Y' : 'N',//是否成功 Y N
				operationType: OPERATION_DEL,
				module: 'WMS',
				source: "PDA",
			}
			basPdaOperationLogFn(opertionParmes)
		} catch (error) {
		}
		if (res.code == 0) {
			store.commit('deleteRMWarehouseChangeList', index)
			uni.showToast({ title: t('fixedAssets.description'), icon: 'none', })
		} else {
			uni.showToast({ title: res.msg, icon: 'none', })
		}
	})
}
</script>

<style></style>
